let express=require(`express`)
let app=express()
let user=require(`./router/user`)
let jwt=require(`express-jwt`)
// let CateList=require(`./router/CateList`)
app.listen(`3000`,console.log('3000端口启动成功'))
app.use(express.urlencoded({extended:true}))
app.use(`uploads`,express.static(`./uploads`))
app.use(
    jwt({
        secret:`hehe`,
        algorithms:[`HS256`]
    }).unless({
        path:['/api/login'],
    }),
)

app.use(user)
app.use(require(`./router/CateList`))
app.use(require(`./router/article`))
app.use((err,req,res,next)=>{
    if(err.name===`UnauthorizedError`){
        res.status(401).send({status:1,message:`身份认证失败！`})
    }
})